/* eslint-disable max-len */
<template>
  <div class="bottom-btns">
    <div>
      <div
        v-for="(item, index) in items"
        :key="index"
        @click="$emit('item-click', item)"
        :class="`bottom-btns-item ${index ? 'liner-before' : ''}`"
      >
        <div :ref="'btnLabel'" class="msg-label">{{ item.name }}</div>
      </div>
    </div>
  </div>
</template>

<script type="text/ecmascript-6">
/*eslint-disable*/
export default {
  props: {
    items: {
      type: Array,
      required:true
    },
    myStyle:{
      type:Object,
      default(){
        return {
        }
      }
    }
  },
  methods: {
    initPage(){
      const { myStyle } = this
      const eles = this.$refs[`btnLabel`]
      const styleArr = []
      for(let key in myStyle){
        const str = `${key}:${myStyle[key]}`
        styleArr.push(str)
      }
      const styleText = styleArr.toString().replace(/,/g,';') + ';'
      eles.map(item => {
        item.style.cssText = styleText
      })
    }
  },
  watch:{
    myStyle:{
      handler:function() {
        this.initPage()
      }
    },
    immediate:true
  }
};
</script>

<style lang="less" scoped>
.bottom-btns {
  box-shadow: 0px -1px 4px 0px rgba(0, 0, 0, 0.06);
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  > div {
    background-color: #fff;
    height: 49px;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    // box-shadow: 1px 1px 3px rgba(0, 0, 0, 0.205);
    .bottom-btns-item {
      width: 100%;
      height: 100%;
      position: relative;
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      &:active {
        transition: 0.2s linear;
        background-color: rgba(0, 0, 0, 0.212);
        position: relative;
        top: 1px;
      }
      .msg-nums {
        font-size: 22px;
        font-family: Arial-BoldMT, Arial;
        font-weight: 600;
        color: #333333e1;
      }
      .msg-label {
        font-size: 17px;
        font-family: PingFangSC-Medium, PingFang SC;
        font-weight: 600;
        color: #333333d5;
        width: 100%;
        height: 100%;
        display: flex;
        align-items: center;
        justify-content: center;
      }
      &.liner-before {
        &::before {
          content: "";
          width: 1px;
          height: 50%;
          position: absolute;
          top: 25%;
          left: 0;
          background-color: #eeeeee;
        }
      }
    }
    .bottom-btns-liner {
      height: 80%;
      top: 10%;
    }
  }
}
</style>
